/* eslint-disable prettier/prettier */
import React, { Component } from 'react';
import {FirstHeaderC,AdvancedSearch ,InfoTipsC,PrimaryC, SecondHeaderC, TradingCompanyC,DATA_ENTRY} from '@/src/components';
import { Form } from 'antd';

class TradingCompanyCTest extends Component {
  constructor(props) {
    super(props);
    this.formRef = React.createRef();
    this.state = {
      loading: true,
      t3: undefined,
      t5:undefined
    };

    setTimeout(() => {
      this.setState({
        t3: '701020411000044606011',
        loading: false,
        t5: '测试会员',
      });
    }, 2000);
  }

  change = () => {
    this.state.TradingCompanyC.setSelect('2016中诚盈聚1号');
  };

  handleGetData=()=>{
    const data=this.formRef.current.getFieldsValue()
    console.log(data)
  }

  handleClick1=()=>{
    this.state.TradingCompanyC1.setSelect(undefined);

  }

  handleClick2=()=>{
    this.state.TradingCompanyC2.setSelect('000000199306297426000');

  }

  render() {
    return (
      <div style={{ width: '800px' }}>
        <Form ref={this.formRef}>
        <PrimaryC style={{marginLeft:'20px',marginBottom:'15px'}} onClick={this.handleGetData} title='获取所有表单数据' />
          <div>
            <InfoTipsC style={{marginLeft:'20px'}} Left="交易对手数据来源dataType 1-全市场 2-交易对手模块 3-银行间交易对手，默认1"/>
            <SecondHeaderC title={'无初始化值--数据来源于全市场'} />
            <TradingCompanyC form={this.formRef.current} dataIndex={'t1'}
             onChange={(e) => console.log(e)} />
            <SecondHeaderC title={'无初始化值--数据来源于交易对手模块'} />
            <TradingCompanyC form={this.formRef.current} dataIndex={'t11'}
             onChange={(e) => console.log(e)} 
             dataType={2} 
             />
            <SecondHeaderC title={'无初始化值--数据来源于银行间'} />
            <TradingCompanyC 
            form={this.formRef.current} 
            dataIndex={'t111'}
             onChange={(e) => console.log(e)} 
             dataType={3} />
          </div>
          <div className='sectionItem'>
            <SecondHeaderC title={'同步加载 initialValue值回填的是title名称 '} />
            <TradingCompanyC
             form={this.formRef.current} 
             dataIndex={'t2'}
            initialValue={"测试会员"}
              // onChange={(e) => console.log('同步title',e)} 
              />
          </div> 
          <div className='sectionItem'>
            <SecondHeaderC title={'异步加载初始化值 initialValue值回填的是title名称 '} />
            <TradingCompanyC
             form={this.formRef.current} 
             dataIndex={'t5'}
              initialValue={this.state.t5}
              onRef={(ref) => {
                this.setState({ TradingCompanyC1: ref });
              }}
              // onChange={(e) => console.log('同步title',e)} 
              />
          </div> 
          <PrimaryC style={{marginLeft:'20px'}} title='变更选项' onClick={this.handleClick1} /> 
          <div className='sectionItem'>
            <SecondHeaderC title={'异步加载初始化值 initialValue值回填的是id,暂时只在dataType=1生效'} />
            <TradingCompanyC
              form={this.formRef.current}
              dataIndex={'t3'}
              scenesType={'3'}
              initialValue={this.state.t3}
              // onChange={(e) => console.log('异步id',e)}
              onRef={(ref) => {
                this.setState({ TradingCompanyC2: ref });
              }}
              loading={this.state.loading}
            />
          </div>
          <PrimaryC style={{marginLeft:'20px'}} title='变更选项' onClick={this.handleClick2} />
         
          <div className='sectionItem'>
            <SecondHeaderC title={'同步加载初始化值 initialValue值回填的是id,暂时只在dataType=1生效'} />
            <TradingCompanyC
              form={this.formRef.current}
              dataIndex={'t6'}
              scenesType={'3'}
              initialValue={'701020411000044606011'}
              // onChange={(e) => console.log('异步id',e)}
             
              loading={this.state.loading}
            />
          </div> 
        </Form>
        <FirstHeaderC title='查询组件用应用' />
        <AdvancedSearch
          dataSource={[
            {
              dataIndex:'ttt',
              type: DATA_ENTRY.TRADINGCOMPANY,
              // initialValue:"测试会员"
            },
            {
              dataIndex: 'other',
              title: '其他查询条件',
              type: DATA_ENTRY.SELECT,
              dataSource: [{ value: 1, title: 1 }],
            },
          ]}
          onQuery={(obj)=>{
            console.log(obj,'queryAdv')
          }}
        />
      </div>
    );
  }
}

export default TradingCompanyCTest;
